﻿using UnityEngine;
using UnityEditor;
using System.Collections;
using System;

namespace UnityEditor.Extension
{
    public static class SerializedObjectExtension
    {
        public static void ForEachVisibleProperty(this SerializedObject source, Action<SerializedProperty> action)
        {
            SerializedProperty property = source.GetIterator();
            bool seekChild = true;
            while (property.NextVisible(seekChild))
            {
                seekChild = false;
                action(property);
            }
        }
        public static void ForEachProperty(this SerializedObject source, Action<SerializedProperty> action)
        {
            SerializedProperty property = source.GetIterator();
            bool seekChild = true;
            while (property.Next(seekChild))
            {
                seekChild = false;
                action(property);
            }
        }
    }
}
